/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package b_and_b_properties.data;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author 09265512
 */
@Entity
@Table(name = "ROOM", catalog = "", schema = "SAPCAPSTONE")
@NamedQueries({
    @NamedQuery(name = "Room.findAll", query = "SELECT r FROM Room r"),
    @NamedQuery(name = "Room.findByIdroom", query = "SELECT r FROM Room r WHERE r.idroom = :idroom"),
    @NamedQuery(name = "Room.findByUnitIdunit", query = "SELECT r FROM Room r WHERE r.unitIdunit = :unitIdunit"),
    @NamedQuery(name = "Room.findByLabel", query = "SELECT r FROM Room r WHERE r.label = :label"),
    @NamedQuery(name = "Room.findByWidth", query = "SELECT r FROM Room r WHERE r.width = :width"),
    @NamedQuery(name = "Room.findByRlength", query = "SELECT r FROM Room r WHERE r.rlength = :rlength"),
    @NamedQuery(name = "Room.findByRlevel", query = "SELECT r FROM Room r WHERE r.rlevel = :rlevel"),
    @NamedQuery(name = "Room.findByFireplace", query = "SELECT r FROM Room r WHERE r.fireplace = :fireplace"),
    @NamedQuery(name = "Room.findByFeatures", query = "SELECT r FROM Room r WHERE r.features = :features")})
public class Room implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "IDROOM")
    private Integer idroom;
//    @Basic(optional = false)
//    @Column(name = "IDUNIT")
    @JoinColumn(name = "UNIT_IDUNIT", referencedColumnName = "IDUNIT")
    @ManyToOne(optional = false)
    private Unit unitIdunit;
    @Column(name = "LABEL")
    private String label;
    @Column(name = "WIDTH")
    private Integer width;
    @Column(name = "RLENGTH")
    private Integer rlength;
    @Column(name = "RLEVEL")
    private Integer rlevel;
    @Column(name = "FIREPLACE")
    private String fireplace;
    @Column(name = "FEATURES")
    private String features;

    public Room() {
    }

    public Room(Integer idroom) {
        this.idroom = idroom;
    }

    public Room(Integer idroom, Unit unitIdunit) {
        this.idroom = idroom;
        this.unitIdunit = unitIdunit;
    }

    public Integer getIdroom() {
        return idroom;
    }

    public void setIdroom(Integer idroom) {
        Integer oldIdroom = this.idroom;
        this.idroom = idroom;
        changeSupport.firePropertyChange("idroom", oldIdroom, idroom);
    }

    public Unit getUnitIdunit() {
        return unitIdunit;
    }

    public void setUnitIdunit(Unit unitIdunit) {
        Unit oldUnitIdunit = this.unitIdunit;
        this.unitIdunit = unitIdunit;
        changeSupport.firePropertyChange("unitIdunit", oldUnitIdunit, unitIdunit);
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        String oldLabel = this.label;
        this.label = label;
        changeSupport.firePropertyChange("label", oldLabel, label);
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        Integer oldWidth = this.width;
        this.width = width;
        changeSupport.firePropertyChange("width", oldWidth, width);
    }

    public Integer getRlength() {
        return rlength;
    }

    public void setRlength(Integer rlength) {
        Integer oldRlength = this.rlength;
        this.rlength = rlength;
        changeSupport.firePropertyChange("rlength", oldRlength, rlength);
    }

    public Integer getRlevel() {
        return rlevel;
    }

    public void setRlevel(Integer rlevel) {
        Integer oldRlevel = this.rlevel;
        this.rlevel = rlevel;
        changeSupport.firePropertyChange("rlevel", oldRlevel, rlevel);
    }

    public String getFireplace() {
        return fireplace;
    }

    public void setFireplace(String fireplace) {
        String oldFireplace = this.fireplace;
        this.fireplace = fireplace;
        changeSupport.firePropertyChange("fireplace", oldFireplace, fireplace);
    }

    public String getFeatures() {
        return features;
    }

    public void setFeatures(String features) {
        String oldFeatures = this.features;
        this.features = features;
        changeSupport.firePropertyChange("features", oldFeatures, features);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idroom != null ? idroom.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Room)) {
            return false;
        }
        Room other = (Room) object;
        if ((this.idroom == null && other.idroom != null) || (this.idroom != null && !this.idroom.equals(other.idroom))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "b_and_b_properties.data.Room[ idroom=" + idroom + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
